#include "Assumption.h"

//Create object with assumption for all digits Can
Assumption::Assumption()
{
    for( int i=1 ; i<10 ; ++i )
    {
        array[ i ] = Can ;
    }
    array [ 0 ] = NotCan ;
}

//Get CanBeInCell for current digit
CanBeInCell Assumption::getAssum( short digit )
{
    return array[ digit ] ;
}

short Assumption::getExclusive()
{
    for( short i=1 ; i<10 ; ++i )
        if( Can == array[i] )
            return i ;
    return 0 ;
}

Assumption::~Assumption() {}

//Add digit in assumption
bool Assumption::addAssum( short digit )
{
    bool old = (Can != array[ digit ] ) ;
    array[ digit ] = Can ;
    return old ;
}

//Delete digit from assumption
bool Assumption::delAssum( short digit )
{
    bool old = (NotCan != array[ digit ] ) ;
    array[ digit ] = NotCan ;
    return old ;
}


bool Assumption::operator== ( const Assumption& assum )
{
    for( int i=0 ; i<10 ; ++i )
        if( array[ i ] != assum.array[ i ] )
            return false ;
    return true ;
}
bool Assumption::operator!= ( const Assumption& assum )
{
    return !(*this == assum) ;
}

std::ostream& operator<<( std::ostream& out, Assumption assum )
{
    for( int i=0 ; i<10 ; ++i)
        if( Can == assum.getAssum( i ) )
            out << i << ' ' ;
    return out ;
}

short Assumption::count()
{
    int count = 0 ;
    for( int i=1 ; i<10 ; ++i )
        if( Can == array[ i ] )
            ++count ;
    return count ;
}
